package ie.dcu.spca.view.item;

import ie.dcu.spca.R;

import com.quietlycoding.android.picker.NumberPicker;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;
import android.widget.TextView;

public class UserCountButtonClickListener implements OnClickListener {

    private ListView parent;
    private int weight;

    public UserCountButtonClickListener(ListView parent, int weight) {
        super();
        this.parent = parent;
        this.weight = weight;
    }

    @Override
    public void onClick(View view) {
        for (int i = 0; i < parent.getChildCount(); i++) {
            View child = parent.getChildAt(i);
            View np = child.findViewById(R.id.userCountNP);
            if (np == null)
                continue;
            View name = child.findViewById(R.id.nameTextView);
            NumberPicker et = (NumberPicker) np;
            TextView tv = (TextView) name;
            if (tv.getText().equals("XTT")) {
                et.setCurrent(0);
            } else
                et.setCurrent(weight);
        }
    }

}
